<template>
  <div class="infoBox">
    <el-drawer
      :visible.sync="dialogVisible"
      :title="isAtud ? $t('shangPinShengHe') : $t('shangPinXinXi')"
      direction="rtl"
      :append-to-body="true"
      custom-class="demo-drawer"
      size="1000px"
      :wrapper-closable="isAtud ? false : true"
      :modal-append-to-body="false"
      class="infoBox"
      :destroy-on-close="true"
    >
      <div class="demo-drawer__content">
        <div class="divBox">
          <div slot="header" class="clearfix">
            <el-tabs v-model="currentTab">
              <el-tab-pane :label="$t('shangPinXinXi')" name="0" />
              <!-- <el-tab-pane :label="$t('shangPinXiangQing')" name="1" /> -->
            </el-tabs>
          </div>
          <el-descriptions v-show="currentTab==='0'" :column="2" border>
            <el-descriptions-item v-for="(item,index) in detailData" :key="index" :label="item.label" :span="item.span||1">
              <el-image
                v-if="item.type==='image'"
                style="width: 100px !important; height: 100px !important;"
                :src="item.value"
                :preview-src-list="[item.value]"
                fit="contain"
              />
              <template v-else>{{ item.value }}</template>
            </el-descriptions-item>
          </el-descriptions>
          <div v-show="currentTab==='1'" v-html="storeInfo" />
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import i18n from '../../../lang/index'
import {
  // productCouponListApi,
  productAuditApi,
  brandListApi,
  productGuaranteeApi,
  // productCreateApi,
  // categoryApi,
  productDetailApi
  // productUpdateApi
} from '@/api/store'
// import { Debounce } from '@/utils/validate'
import { mapGetters } from 'vuex'
import { detectLanguage, isJSON } from '@/utils/index.js'

export default {
  name: 'ProductProductAdd',
  props: {
    isShow: {
      type: Boolean,
      default: true
    },
    isAtud: {
      type: Boolean,
      default: false
    },
    productId: {
      type: [Number, String],
      default: () => null
    }
  },
  data() {
    return {
      dialogVisible: false,
      currentTab: '0',
      grid: {
        xl: 12,
        lg: 12,
        md: 12,
        sm: 24,
        xs: 24
      },
      detailData: [],
      storeInfo: ''
    }
  },
  computed: {
    ...mapGetters([
      'merProductClassify',
      'merProductClassifyArr',
      'productBrand',
      'translateNameProductClassify',
      'translateMerProductClassifyArr',
      'translateAdminProductClassifyArr'
    ])
  },
  created() {

  },
  mounted() {
    if (!this.translateAdminProductClassifyArr.length) this.$store.dispatch('product/getAdminProductClassify');
  },
  methods: {
    close() {
      this.dialogVisible = false
    },
    getInfo(id) {
      this.loading = true
      productDetailApi(id).then(res => {
        this.detailData = [
          { label: this.$t('shangPinId'), value: res.skuCode },
          { label: this.$t('shangPinMingCheng'), value: res.storeName },
          { label: this.$t('shangPinWeiYiMa'), value: res.skuOnlyCode },
          { label: this.$t('shangPinGuiGe'), value: res.specType ? this.$t('duoGuiGe') : this.$t('danGuiGe') },
          { label: this.$t('shangPinFenLei'), value: this.getCategoryName(res.categoryId) },
          { label: this.$t('pinPai'), value: res.brandName },
          { label: this.$t('zheKouJia'), value: res.price },
          { label: this.$t('yuanJia'), value: res.originalPrice },
          { label: 'HSCODE', value: res.hsCode },
          { label: this.$t('shiFouDaiDian'), value: res.electricityFlag === 'Y' ? this.$t('yes') : this.$t('no') },
          { label: this.$t('shangPinChiCun'), value: `${res.skuLength}*${res.skuWidth}*${res.skuHeight} CM` },
          { label: this.$t('zhongLiang'), value: `${res.skuWeight}KG` },
          { label: this.$t('yanSe'), value: res.skuColor },
          { label: this.$t('xingHao'), value: res.skuModel },
          { label: this.$t('kuCunShu'), value: res.stock, span: 2 },
          { label: this.$t('shangPinZhuTu'), value: res.image, type: 'image', span: 2 },
          { label: this.$t('shangPinZhanShiTu'), value: res.flatPattern, type: 'image', span: 2 },
          { label: this.$t('shangPinLunBoTu'), value: res.sliderImage, type: 'image', span: 2 },
          { label: this.$t('shangPinXiangQing'), value: res.storeInfo, span: 2 },
          { label: this.$t('juJueYuanYin0'), value: res.reason, span: 2 }
        ]
        this.storeInfo = res.content
      })
    },
    getCategoryName(categoryId) {
      const obj = this.translateAdminProductClassifyArr.find((e) => {
        return e.id == categoryId
      })
      return obj ? obj.translateName : ''
    }
  }
}
</script>
<style scoped lang="scss">
.spfont {
  color: #606266;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.from-foot-btn {
  width: 100%;
  padding: 20px;
}
.fix {
  z-index: 10;
  position: absolute;
  left: 0;
  bottom: 0px;
  padding-bottom: 10px;
  background: #fff;
}
.btn-shadow {
  box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.05);
}
.infoBox {
  ::v-deep.el-drawer__header {
    margin-bottom: 0;
    font-size: 20px;
  }
  ::v-deep .el-input.is-disabled .el-input__inner {
    background: none;
    cursor: none;
    color: #606266;
  }
  ::v-deep.el-icon-arrow-down,
  ::v-deep .el-icon-arrow-up {
    display: none;
  }
}
.divBox {
  ::v-deep .el-input__inner,
  ::v-deep .el-input__inner:hover,
  ::v-deep.el-input > input,
  ::v-deep.el-textarea > textarea {
    border: none;
    padding: 0;
  }
  ::v-deep .el-form-item {
    margin-bottom: 0;
  }
  ::v-deep.el-card__body {
    padding: 5px;
  }
}
.disLabel {
  ::v-deep .el-form-item__label {
    margin-left: 36px !important;
  }
}
.disLabelmoren {
  ::v-deep.el-form-item__label {
    margin-left: 120px !important;
  }
}
.priamry_border {
  border: 1px solid #1890ff;
  color: #1890ff;
}
.color-item {
  height: 30px;
  line-height: 30px;
  padding: 0 10px;
  color: #fff;
  margin-right: 10px;
}
.color-list .color-item.blue {
  background-color: #1e9fff;
}
.color-list .color-item.yellow {
  background-color: rgb(254, 185, 0);
}
.color-list .color-item.green {
  background-color: #009688;
}
.color-list .color-item.red {
  background-color: #ed4014;
}
.proCoupon {
  ::v-deepel-form-item__content {
    margin-top: 5px;
  }
}
.tabPic {
  width: 40px !important;
  height: 40px !important;
  img {
    width: 100%;
    height: 100%;
  }
}
.noLeft {
  ::v-deepel-form-item__content {
    margin-left: 0 !important;
  }
}
/*.tabNumWidth{*/
/*::v-deepel-input-number--medium{*/
/*width: 121px !important;*/
/*}*/
/*::v-deepel-input-number__increase{*/
/*width: 20px !important;*/
/*font-size: 12px !important;*/
/*}*/
/*::v-deepel-input-number__decrease{*/
/*width: 20px !important;*/
/*font-size: 12px !important;*/
/*}*/
/*::v-deepel-input-number--medium .el-input__inner {*/
/*padding-left: 25px !important;*/
/*padding-right: 25px !important;*/
/*}*/
/*::v-deep thead{*/
/*line-height: normal !important;*/
/*}*/
/*::v-deep .el-table .cell{*/
/*line-height: normal !important;*/
/*}*/
/*}*/
.selWidth {
  width: 100%;
}
.selWidthd {
  width: 100px;
}
.button-new-tag {
  height: 28px;
  line-height: 26px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}
.pictrue {
  width: 60px;
  height: 60px;
  border: 1px dotted rgba(0, 0, 0, 0.1);
  margin-right: 10px;
  position: relative;
  cursor: pointer;
  img {
    width: 100%;
    height: 100%;
  }
  video {
    width: 100%;
    height: 100%;
  }
}
.labeltop {
  ::v-deepel-form-item__label {
    float: none !important;
    display: inline-block !important;
    width: auto !important;
  }
}
.iview-video-style {
  width: 300px;
  height: 180px;
  border-radius: 10px;
  background-color: #707070;
  margin: 0 120px 20px;
  position: relative;
  overflow: hidden;
}

.iview-video-style .iconv {
  color: #fff;
  line-height: 180px;
  width: 50px;
  height: 50px;
  display: inherit;
  font-size: 26px;
  position: absolute;
  top: -74px;
  left: 50%;
  margin-left: -25px;
}

.iview-video-style .mark {
  position: absolute;
  width: 100%;
  height: 30px;
  top: 0;
  background-color: rgba(0, 0, 0, 0.5);
  text-align: center;
}
.tag + .tag {
  margin-left: 10px;
}
.mb-30 {
  margin-bottom: 30px;
}
::v-deep .el-descriptions{
  .el-descriptions-item__label.is-bordered-label{
    min-width: 100px;
  }
  .el-descriptions-item__cell{
    white-space: normal; /* 保留空白符序列，但是正常换行 */
    word-break: break-all;
  }
}
</style>
